﻿using System;
using System.ComponentModel;
using System.Reflection;
using System.Runtime.InteropServices;
using Teigha.Core;

namespace Teigha.TD
{
	public class OdDbTransactionReactor : OdRxObject
	{
		[EditorBrowsable(EditorBrowsableState.Never)]
		public OdDbTransactionReactor(IntPtr cPtr, bool cMemoryOwn) : base(TD_DbPINVOKE.OdDbTransactionReactor_SWIGUpcast(cPtr), cMemoryOwn)
		{
			this.swigCPtr = new HandleRef(this, cPtr);
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static HandleRef getCPtr(OdDbTransactionReactor obj)
		{
			if (obj != null)
			{
				return obj.swigCPtr;
			}
			return new HandleRef(null, IntPtr.Zero);
		}

		~OdDbTransactionReactor()
		{
			this.Dispose();
		}

		public override void Dispose()
		{
			if (this.swigCPtr.Handle != IntPtr.Zero)
			{
				if (this.swigCMemOwn)
				{
					lock (this.locker)
					{
						if (this.swigCPtr.Handle != IntPtr.Zero && this.swigCMemOwn)
						{
							this.swigCMemOwn = false;
							TD_DbPINVOKE.delete_OdDbTransactionReactor(this.swigCPtr);
						}
					}
					this.swigCMemOwn = false;
				}
				this.swigCPtr = new HandleRef(null, IntPtr.Zero);
			}
			GC.SuppressFinalize(this);
			base.Dispose();
		}

		public OdDbTransactionReactor() : this(TD_DbPINVOKE.new_OdDbTransactionReactor(), MemoryManager.GetMemoryManager().GetCurrentTransaction() == null)
		{
			MemoryTransaction currentTransaction = MemoryManager.GetMemoryManager().GetCurrentTransaction();
			if (currentTransaction != null)
			{
				currentTransaction.AddObject(new OdDbTransactionReactor(this.swigCPtr.Handle, true));
			}
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			this.SwigDirectorConnect();
		}

		public new static OdDbTransactionReactor cast(OdRxObject pObj)
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = TD_DbPINVOKE.OdDbTransactionReactor_cast(OdRxObject.getCPtr(pObj));
			OdDbTransactionReactor result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdDbTransactionReactor)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdDbTransactionReactor)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdDbTransactionReactor)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new static OdRxClass desc()
		{
			OdRxClass result = (OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(TD_DbPINVOKE.OdDbTransactionReactor_desc(), false);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdRxClass isA()
		{
			OdRxClass result = (OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(this.SwigDerivedClassHasMethod("isA", OdDbTransactionReactor.swigMethodTypes1) ? TD_DbPINVOKE.OdDbTransactionReactor_isASwigExplicitOdDbTransactionReactor(this.swigCPtr) : TD_DbPINVOKE.OdDbTransactionReactor_isA(this.swigCPtr), false);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdRxObject queryX(OdRxClass protocolClass)
		{
			OdRxObject result = Teigha.Core.Helpers.odrxCreateObjectInternal(this.SwigDerivedClassHasMethod("queryX", OdDbTransactionReactor.swigMethodTypes0) ? TD_DbPINVOKE.OdDbTransactionReactor_queryXSwigExplicitOdDbTransactionReactor(this.swigCPtr, OdRxClass.getCPtr(protocolClass)) : TD_DbPINVOKE.OdDbTransactionReactor_queryX(this.swigCPtr, OdRxClass.getCPtr(protocolClass)), false);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public static OdDbTransactionReactor createObject()
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = TD_DbPINVOKE.OdDbTransactionReactor_createObject();
			OdDbTransactionReactor result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdDbTransactionReactor)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdDbTransactionReactor)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdDbTransactionReactor)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual void transactionAboutToStart(OdDbDatabase pDb)
		{
			if (this.SwigDerivedClassHasMethod("transactionAboutToStart", OdDbTransactionReactor.swigMethodTypes2))
			{
				TD_DbPINVOKE.OdDbTransactionReactor_transactionAboutToStartSwigExplicitOdDbTransactionReactor(this.swigCPtr, OdDbDatabase.getCPtr(pDb));
			}
			else
			{
				TD_DbPINVOKE.OdDbTransactionReactor_transactionAboutToStart(this.swigCPtr, OdDbDatabase.getCPtr(pDb));
			}
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual void transactionStarted(OdDbDatabase pDb)
		{
			if (this.SwigDerivedClassHasMethod("transactionStarted", OdDbTransactionReactor.swigMethodTypes3))
			{
				TD_DbPINVOKE.OdDbTransactionReactor_transactionStartedSwigExplicitOdDbTransactionReactor(this.swigCPtr, OdDbDatabase.getCPtr(pDb));
			}
			else
			{
				TD_DbPINVOKE.OdDbTransactionReactor_transactionStarted(this.swigCPtr, OdDbDatabase.getCPtr(pDb));
			}
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual void transactionAboutToEnd(OdDbDatabase pDb)
		{
			if (this.SwigDerivedClassHasMethod("transactionAboutToEnd", OdDbTransactionReactor.swigMethodTypes4))
			{
				TD_DbPINVOKE.OdDbTransactionReactor_transactionAboutToEndSwigExplicitOdDbTransactionReactor(this.swigCPtr, OdDbDatabase.getCPtr(pDb));
			}
			else
			{
				TD_DbPINVOKE.OdDbTransactionReactor_transactionAboutToEnd(this.swigCPtr, OdDbDatabase.getCPtr(pDb));
			}
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual void transactionEnded(OdDbDatabase pDb)
		{
			if (this.SwigDerivedClassHasMethod("transactionEnded", OdDbTransactionReactor.swigMethodTypes5))
			{
				TD_DbPINVOKE.OdDbTransactionReactor_transactionEndedSwigExplicitOdDbTransactionReactor(this.swigCPtr, OdDbDatabase.getCPtr(pDb));
			}
			else
			{
				TD_DbPINVOKE.OdDbTransactionReactor_transactionEnded(this.swigCPtr, OdDbDatabase.getCPtr(pDb));
			}
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual void transactionAboutToAbort(OdDbDatabase pDb)
		{
			if (this.SwigDerivedClassHasMethod("transactionAboutToAbort", OdDbTransactionReactor.swigMethodTypes6))
			{
				TD_DbPINVOKE.OdDbTransactionReactor_transactionAboutToAbortSwigExplicitOdDbTransactionReactor(this.swigCPtr, OdDbDatabase.getCPtr(pDb));
			}
			else
			{
				TD_DbPINVOKE.OdDbTransactionReactor_transactionAboutToAbort(this.swigCPtr, OdDbDatabase.getCPtr(pDb));
			}
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual void transactionAborted(OdDbDatabase pDb)
		{
			if (this.SwigDerivedClassHasMethod("transactionAborted", OdDbTransactionReactor.swigMethodTypes7))
			{
				TD_DbPINVOKE.OdDbTransactionReactor_transactionAbortedSwigExplicitOdDbTransactionReactor(this.swigCPtr, OdDbDatabase.getCPtr(pDb));
			}
			else
			{
				TD_DbPINVOKE.OdDbTransactionReactor_transactionAborted(this.swigCPtr, OdDbDatabase.getCPtr(pDb));
			}
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual void endCalledOnOutermostTransaction(OdDbDatabase pDb)
		{
			if (this.SwigDerivedClassHasMethod("endCalledOnOutermostTransaction", OdDbTransactionReactor.swigMethodTypes8))
			{
				TD_DbPINVOKE.OdDbTransactionReactor_endCalledOnOutermostTransactionSwigExplicitOdDbTransactionReactor(this.swigCPtr, OdDbDatabase.getCPtr(pDb));
			}
			else
			{
				TD_DbPINVOKE.OdDbTransactionReactor_endCalledOnOutermostTransaction(this.swigCPtr, OdDbDatabase.getCPtr(pDb));
			}
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual void objectIdSwapped(OdDbObject pTransObj, OdDbObject pOtherTransObj, OdDbDatabase pDb)
		{
			if (this.SwigDerivedClassHasMethod("objectIdSwapped", OdDbTransactionReactor.swigMethodTypes9))
			{
				TD_DbPINVOKE.OdDbTransactionReactor_objectIdSwappedSwigExplicitOdDbTransactionReactor(this.swigCPtr, OdDbObject.getCPtr(pTransObj), OdDbObject.getCPtr(pOtherTransObj), OdDbDatabase.getCPtr(pDb));
			}
			else
			{
				TD_DbPINVOKE.OdDbTransactionReactor_objectIdSwapped(this.swigCPtr, OdDbObject.getCPtr(pTransObj), OdDbObject.getCPtr(pOtherTransObj), OdDbDatabase.getCPtr(pDb));
			}
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		private void SwigDirectorConnect()
		{
			if (this.SwigDerivedClassHasMethod("queryX", OdDbTransactionReactor.swigMethodTypes0))
			{
				this.swigDelegate0 = new OdDbTransactionReactor.SwigDelegateOdDbTransactionReactor_0(this.SwigDirectorqueryX);
			}
			if (this.SwigDerivedClassHasMethod("isA", OdDbTransactionReactor.swigMethodTypes1))
			{
				this.swigDelegate1 = new OdDbTransactionReactor.SwigDelegateOdDbTransactionReactor_1(this.SwigDirectorisA);
			}
			if (this.SwigDerivedClassHasMethod("transactionAboutToStart", OdDbTransactionReactor.swigMethodTypes2))
			{
				this.swigDelegate2 = new OdDbTransactionReactor.SwigDelegateOdDbTransactionReactor_2(this.SwigDirectortransactionAboutToStart);
			}
			if (this.SwigDerivedClassHasMethod("transactionStarted", OdDbTransactionReactor.swigMethodTypes3))
			{
				this.swigDelegate3 = new OdDbTransactionReactor.SwigDelegateOdDbTransactionReactor_3(this.SwigDirectortransactionStarted);
			}
			if (this.SwigDerivedClassHasMethod("transactionAboutToEnd", OdDbTransactionReactor.swigMethodTypes4))
			{
				this.swigDelegate4 = new OdDbTransactionReactor.SwigDelegateOdDbTransactionReactor_4(this.SwigDirectortransactionAboutToEnd);
			}
			if (this.SwigDerivedClassHasMethod("transactionEnded", OdDbTransactionReactor.swigMethodTypes5))
			{
				this.swigDelegate5 = new OdDbTransactionReactor.SwigDelegateOdDbTransactionReactor_5(this.SwigDirectortransactionEnded);
			}
			if (this.SwigDerivedClassHasMethod("transactionAboutToAbort", OdDbTransactionReactor.swigMethodTypes6))
			{
				this.swigDelegate6 = new OdDbTransactionReactor.SwigDelegateOdDbTransactionReactor_6(this.SwigDirectortransactionAboutToAbort);
			}
			if (this.SwigDerivedClassHasMethod("transactionAborted", OdDbTransactionReactor.swigMethodTypes7))
			{
				this.swigDelegate7 = new OdDbTransactionReactor.SwigDelegateOdDbTransactionReactor_7(this.SwigDirectortransactionAborted);
			}
			if (this.SwigDerivedClassHasMethod("endCalledOnOutermostTransaction", OdDbTransactionReactor.swigMethodTypes8))
			{
				this.swigDelegate8 = new OdDbTransactionReactor.SwigDelegateOdDbTransactionReactor_8(this.SwigDirectorendCalledOnOutermostTransaction);
			}
			if (this.SwigDerivedClassHasMethod("objectIdSwapped", OdDbTransactionReactor.swigMethodTypes9))
			{
				this.swigDelegate9 = new OdDbTransactionReactor.SwigDelegateOdDbTransactionReactor_9(this.SwigDirectorobjectIdSwapped);
			}
			TD_DbPINVOKE.OdDbTransactionReactor_director_connect(this.swigCPtr, this.swigDelegate0, this.swigDelegate1, this.swigDelegate2, this.swigDelegate3, this.swigDelegate4, this.swigDelegate5, this.swigDelegate6, this.swigDelegate7, this.swigDelegate8, this.swigDelegate9);
		}

		private bool SwigDerivedClassHasMethod(string methodName, Type[] methodTypes)
		{
			MethodInfo method = base.GetType().GetMethod(methodName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, methodTypes, null);
			return method.DeclaringType.IsSubclassOf(typeof(OdDbTransactionReactor));
		}

		private IntPtr SwigDirectorqueryX(IntPtr protocolClass)
		{
			return OdRxObject.getCPtr(this.queryX((OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(protocolClass, false))).Handle;
		}

		private IntPtr SwigDirectorisA()
		{
			return OdRxClass.getCPtr(this.isA()).Handle;
		}

		private void SwigDirectortransactionAboutToStart(IntPtr pDb)
		{
			this.transactionAboutToStart((OdDbDatabase)Teigha.Core.Helpers.odrxCreateObjectInternal(pDb, false));
		}

		private void SwigDirectortransactionStarted(IntPtr pDb)
		{
			this.transactionStarted((OdDbDatabase)Teigha.Core.Helpers.odrxCreateObjectInternal(pDb, false));
		}

		private void SwigDirectortransactionAboutToEnd(IntPtr pDb)
		{
			this.transactionAboutToEnd((OdDbDatabase)Teigha.Core.Helpers.odrxCreateObjectInternal(pDb, false));
		}

		private void SwigDirectortransactionEnded(IntPtr pDb)
		{
			this.transactionEnded((OdDbDatabase)Teigha.Core.Helpers.odrxCreateObjectInternal(pDb, false));
		}

		private void SwigDirectortransactionAboutToAbort(IntPtr pDb)
		{
			this.transactionAboutToAbort((OdDbDatabase)Teigha.Core.Helpers.odrxCreateObjectInternal(pDb, false));
		}

		private void SwigDirectortransactionAborted(IntPtr pDb)
		{
			this.transactionAborted((OdDbDatabase)Teigha.Core.Helpers.odrxCreateObjectInternal(pDb, false));
		}

		private void SwigDirectorendCalledOnOutermostTransaction(IntPtr pDb)
		{
			this.endCalledOnOutermostTransaction((OdDbDatabase)Teigha.Core.Helpers.odrxCreateObjectInternal(pDb, false));
		}

		private void SwigDirectorobjectIdSwapped(IntPtr pTransObj, IntPtr pOtherTransObj, IntPtr pDb)
		{
			this.objectIdSwapped((OdDbObject)Teigha.Core.Helpers.odrxCreateObjectInternal(pTransObj, false), (OdDbObject)Teigha.Core.Helpers.odrxCreateObjectInternal(pOtherTransObj, false), (OdDbDatabase)Teigha.Core.Helpers.odrxCreateObjectInternal(pDb, false));
		}

		private object locker = new object();

		private HandleRef swigCPtr;

		private OdDbTransactionReactor.SwigDelegateOdDbTransactionReactor_0 swigDelegate0;

		private OdDbTransactionReactor.SwigDelegateOdDbTransactionReactor_1 swigDelegate1;

		private OdDbTransactionReactor.SwigDelegateOdDbTransactionReactor_2 swigDelegate2;

		private OdDbTransactionReactor.SwigDelegateOdDbTransactionReactor_3 swigDelegate3;

		private OdDbTransactionReactor.SwigDelegateOdDbTransactionReactor_4 swigDelegate4;

		private OdDbTransactionReactor.SwigDelegateOdDbTransactionReactor_5 swigDelegate5;

		private OdDbTransactionReactor.SwigDelegateOdDbTransactionReactor_6 swigDelegate6;

		private OdDbTransactionReactor.SwigDelegateOdDbTransactionReactor_7 swigDelegate7;

		private OdDbTransactionReactor.SwigDelegateOdDbTransactionReactor_8 swigDelegate8;

		private OdDbTransactionReactor.SwigDelegateOdDbTransactionReactor_9 swigDelegate9;

		private static Type[] swigMethodTypes0 = new Type[]
		{
			typeof(OdRxClass)
		};

		private static Type[] swigMethodTypes1 = new Type[0];

		private static Type[] swigMethodTypes2 = new Type[]
		{
			typeof(OdDbDatabase)
		};

		private static Type[] swigMethodTypes3 = new Type[]
		{
			typeof(OdDbDatabase)
		};

		private static Type[] swigMethodTypes4 = new Type[]
		{
			typeof(OdDbDatabase)
		};

		private static Type[] swigMethodTypes5 = new Type[]
		{
			typeof(OdDbDatabase)
		};

		private static Type[] swigMethodTypes6 = new Type[]
		{
			typeof(OdDbDatabase)
		};

		private static Type[] swigMethodTypes7 = new Type[]
		{
			typeof(OdDbDatabase)
		};

		private static Type[] swigMethodTypes8 = new Type[]
		{
			typeof(OdDbDatabase)
		};

		private static Type[] swigMethodTypes9 = new Type[]
		{
			typeof(OdDbObject),
			typeof(OdDbObject),
			typeof(OdDbDatabase)
		};

		public delegate IntPtr SwigDelegateOdDbTransactionReactor_0(IntPtr protocolClass);

		public delegate IntPtr SwigDelegateOdDbTransactionReactor_1();

		public delegate void SwigDelegateOdDbTransactionReactor_2(IntPtr pDb);

		public delegate void SwigDelegateOdDbTransactionReactor_3(IntPtr pDb);

		public delegate void SwigDelegateOdDbTransactionReactor_4(IntPtr pDb);

		public delegate void SwigDelegateOdDbTransactionReactor_5(IntPtr pDb);

		public delegate void SwigDelegateOdDbTransactionReactor_6(IntPtr pDb);

		public delegate void SwigDelegateOdDbTransactionReactor_7(IntPtr pDb);

		public delegate void SwigDelegateOdDbTransactionReactor_8(IntPtr pDb);

		public delegate void SwigDelegateOdDbTransactionReactor_9(IntPtr pTransObj, IntPtr pOtherTransObj, IntPtr pDb);
	}
}
